package com.ying.user.service.impl;

import com.ying.common.entity.Response;
import com.ying.user.dao.MmRoleDao;
import com.ying.user.entity.MmRole;
import com.ying.user.service.MmRoleService;
import com.ying.user.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.function.Function;

@Service
public class MmRoleServiceImpl implements MmRoleService {

    @Autowired
    private MmRoleDao mmRoleDao;

    @Override
    public Function<MmRole, Response> add() {
        return (mmRole) -> {
            Response response = new Response();
            mmRole.setDescription("测试角色");
            mmRole.setCreateTime(DateUtils.getDateTime());
            mmRole.setUpdateTime(DateUtils.getDateTime());
            int i = mmRoleDao.insertSelective(mmRole);
            return i > 0 ? response.success("添加角色成功") : response.failure("添加角色失败");
        };
    }
}
